package com.sikaryofficial.backend.controller.information;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sikaryofficial.backend.annotation.Repeat;
import com.sikaryofficial.backend.domain.dto.req.information.ArticleEvaluateReplyListReq;
import com.sikaryofficial.backend.domain.dto.req.information.ArticleEvaluateReplyReq;
import com.sikaryofficial.backend.domain.dto.resp.information.ArticleEvaluateReplyDTO;
import com.sikaryofficial.backend.manager.information.ArticleEvaluateReplyManager;
import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.common.core.utils.PageUtil;
import com.sikaryofficial.common.core.web.controller.BaseController;
import com.sikaryofficial.common.core.web.domain.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文章评价回复Controller
 *
 * @author qinjinyuan
 * @date 2024-03-15
 */
@RestController
@RequestMapping("/article/evaluateReply")
@Api(tags = "资讯-文章评价回复")
public class ArticleEvaluateReplyController extends BaseController {
    @Autowired
    private ArticleEvaluateReplyManager replyManager;

    /**
     * 查询文章评价回复列表
     */
    @PostMapping("/listPage")
    @ApiOperation("文章评价回复分页列表")
    public PageResult<ArticleEvaluateReplyDTO> listPage(@Validated @RequestBody ArticleEvaluateReplyListReq req) {
        IPage<ArticleEvaluateReplyDTO> page = replyManager.listPage(req);
        return PageUtil.success(page.getRecords(), page.getTotal());
    }

    /**
     * 新增文章评价回复
     */
    @PostMapping("/add")
    @ApiOperation("新增文章评价回复")
    @Repeat
    public R<ArticleEvaluateReplyDTO> save(@Validated @RequestBody ArticleEvaluateReplyReq req) {
        return R.ok(replyManager.save(req));
    }
}
